package com.example.demo.person.enums;

import java.util.Arrays;

public enum MaritalStatusEnum {

    /**
     * 婚姻状况
     */
    unmarried(0,"未婚"),
    married(1,"已婚");

    public final Integer code;

    public final String desc;

    MaritalStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static String getDescByCode(Integer code){
        MaritalStatusEnum maritalStatusEnum = Arrays.stream(MaritalStatusEnum.values()).filter(i -> i.code.equals(code)).findAny().orElse(null);
        return maritalStatusEnum == null ? null : maritalStatusEnum.desc;
    }
}
